package fr.umlv.m2.jee.pmlv.service.planning.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import fr.umlv.m2.jee.pmlv.persistence.planning.Classroom;
import fr.umlv.m2.jee.pmlv.persistence.planning.EventExam;
import fr.umlv.m2.jee.pmlv.persistence.planning.dao.IEventExamDAO;
import fr.umlv.m2.jee.pmlv.service.planning.DisplayAbstractEvent;
import fr.umlv.m2.jee.pmlv.service.planning.IDisplayEventExamService;

@Service("defautDisplayEventExamService")
public class DefautDisplayEventExamService implements IDisplayEventExamService{
	
	@Autowired
	@Qualifier("hibernateEventExamDAO")
	private IEventExamDAO dao;
	
	@Override
        @Transactional(readOnly=true)
	public List<DisplayAbstractEvent> getExamByWeekAndByProfessorUid(GregorianCalendar start, String uid) {
            ArrayList< DisplayAbstractEvent > result = new ArrayList< DisplayAbstractEvent >(16);
            /* for(EventExam eventExam : dao.findByWeek(start) ) {
                result.add(new DisplayEventExam(eventExam));
            }*/
            EventExam e = new EventExam();
            e.setBegin(new Date(111, 03, 05, 14, 00));
            e.setEnd(new Date(111, 03, 05, 16, 00));
            Classroom c = new Classroom(); c.setNumber("2B105"); e.setClassroom(c);
            result.add(new DisplayAbstractEvent(e));
            return result;
	}

	@Override
        @Transactional
	public void addEvent(EventExam eventExam) {
		dao.merge(eventExam);
	}
}
